/*
 * 作者：姚俊
 * 功能：用于学科管理用户修改密码的action
 * 日期：2015-05-22
 */
package admin.action.baseInfo;

import admin.service.member.TeacherService;

import com.opensymphony.xwork2.ActionContext;

import teacher.bean.Teacher;
import teacher.service.teacher;

public class AdminExitAction {

	
	private Teacher admin;
	private Teacher teacher;
	private String password1;
	private String password2;
	//当修改成功的时候回出现提示
	private String flag;

	

	public Teacher getAdmin() {
		return admin;
	}

	public void setAdmin(Teacher admin) {
		this.admin = admin;
	}
	
	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	public String getPassword1() {
		return password1;
	}

	public void setPassword1(String password1) {
		this.password1 = password1;
	}

	public String getPassword2() {
		return password2;
	}

	public void setPassword2(String password2) {
		this.password2 = password2;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public String execute()
	{
		
		Teacher tea=(Teacher)ActionContext.getContext().getSession().get("admin");
		this.setTeacher(tea);
		System.out.println("当前的用户名为:"+this.getTeacher().getUser());
		if(tea.getPassword().equals(this.getAdmin().getPassword()))
		{
			System.out.println("姓名为:"+tea.getName());
			tea=new teacher().SelectTeacher(tea);
			tea.setPassword(this.getPassword1());
			new TeacherService().updateTeacher(tea, tea);
			ActionContext.getContext().getSession().put("admin",tea);
			this.setFlag("succ");
			return "succ";
		}
		else
		{
			this.setFlag("err");
			return "succ";
		}
		
	}
}
